#!/usr/bin/env python
# coding=utf-8
"""
# @Created on : 2016/05/05 17:35
# @Author     : ldf (ldf@eehello.com)
# @Link       : http://www.eehello.com
# @Version    : 
# 本程序在python2.7下测试通过
"""

import MySQLdb

class my_mysql(object):

    def __init__(self):
        pass


    def chaxun_fenzu(self,queue):

        self.queue = queue

        conn = MySQLdb.connect(host='10.41.4.230',
                               user='root',
                               passwd='12345',
                               db='oldboy',
                               port=3306,
                               charset='utf8')
        cur = conn.cursor()

        sql_cmd = 'select distinct(zuming) from day6_zuoye'
        #print sql_cmd

        cur.execute(sql_cmd)
        #conn.commit()
        aa = cur.fetchall()
        for i in aa:
            self.queue.put(i[0])

        cur.close()
        conn.close()

    def cmd_fenzu(self,queue,zuming):

        self.queue_cmd = queue
        self.zuming = zuming

        conn = MySQLdb.connect(host='10.41.4.230',
                               user='root',
                               passwd='12345',
                               db='oldboy',
                               port=3306,
                               charset='utf8')
        cur = conn.cursor()

        sql_cmd = 'select host,port,user,pw from day6_zuoye where zuming=%s'
        #print sql_cmd

        cur.execute(sql_cmd,(self.zuming,))
        #conn.commit()
        aa = cur.fetchall()
        for i in aa:
            self.queue_cmd.put(i)


        cur.close()
        conn.close()

'''
a = my_mysql()

from Queue import Queue

q = Queue(maxsize=20)
a.cmd_fenzu(q,'zu2')
for i in range(q.qsize()):
    print q.get()
'''
